package com.ascentive.finallyfast.deepclean;

import com.ascentive.finallyfast.FinallyFastApplication;

public class CallLogHistory extends DeepCleanListItem {

	static int noOfCallsDeleted = 0;
	
	public CallLogHistory(FinallyFastApplication app, String name,
			boolean value, int img) {
		super(app, name, value, img);
	}

	void doClean()
	{
		
	}
	
//	void doClean() {
//
//		int callDeleteStatus = 0;
//		// Uri for CALL_LOG
//		Uri allCalls = Uri.parse("content://call_log/calls");
//
//		// Define projection
//		String[] projection = new String[] { Calls.TYPE, Calls.NUMBER,
//				Calls.DATE, Calls.CACHED_NAME, Calls.DURATION };
//
//		// Query the CallLog for details
//		// Details from the CallLog to be returned Calls are listed in order of
//		// date of occurrence, with recent calls at the top
//        
//		Cursor c = mApp.getContentResolver().query(allCalls, projection, 
//				 "date <= (" + Utility.getDateBeforeNDays(mApp.getTargetDateDuration() ) +")",
//				//null,
//				null, Calls.DATE + " DESC");
//
//		// Find past date depend on selected duration
//		long pastDate = Utility.getDateBeforeNDays( mApp.getTargetDateDuration() );
//
//		int count = c.getCount();
//		if(c.moveToFirst())
//			callDeleteStatus = mApp.getContentResolver().delete(allCalls, null,
//			 	null);
//		
//		noOfCallsDeleted += callDeleteStatus;
//		
//		/*
//		//System.out.println("Number of total calls"+ c.getCount());
//		if (c.moveToFirst()) {
//			do { // For each result returned, the following occurs
//
//				String phNo =
//				c.getString(c.getColumnIndex(CallLog.Calls.NUMBER));
//				String length =
//				c.getString(c.getColumnIndex(CallLog.Calls.DURATION));
//				String dateOfCall = c.getString(c
//						.getColumnIndex(CallLog.Calls.DATE));
////				String typeOfCall = c.getString(c
////						.getColumnIndex(CallLog.Calls.TYPE));
//
//				long lDateOfCall = (long) Double.parseDouble(dateOfCall);
////
////				SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.US);
////		    	String dateString = formatter.format(new Date(lDateOfCall));
//		    	
//		    	
//				// System.out.println("Call Date");
//
//				if (lDateOfCall < pastDate) {
////					System.out.println(typeOfCall);
////					if(typeOfCall.equals("2")) // Outgoing Calls
////					{
////					System.out.println(phNo);
////					System.out.println(length);
////					System.out.println(dateString);
////					}
//
//					callDeleteStatus = mApp.getContentResolver().delete(allCalls, null,
//						 	null);
//					noOfCallsDeleted += callDeleteStatus;
//				}
//			} while (c.moveToNext());
//			
//		}*/
//
//		if (noOfCallsDeleted >= 1) {
//			String displayStr = new String();
//			displayStr += noOfCallsDeleted;
//			displayStr += " Numbers deleted";
//			
//			System.out.println("Number of calls deleted =="+ noOfCallsDeleted);
//			
//			Toast.makeText(mApp.getApplicationContext(), displayStr,
//					Toast.LENGTH_SHORT).show();
//		} else {
//			Toast.makeText(mApp.getApplicationContext(),
//					"No such number in call logs", Toast.LENGTH_SHORT).show();
//		}
//
//		// this.setNoOfFilesCleaned(noOfCallsDeleted);
//		return;
//
//	}

	@Override
	int numberOfFileCleaned() {
		// TODO Auto-generated method stub
		return noOfCallsDeleted;
	}
}